<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<title>聊天室</title>
<link href="CSS/style.css" rel="stylesheet">
<script type="text/javascript" src="${ pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	//刷新验证码
	function myReload(){
		$("#CreateCheckCode").attr("src","${pageContext.request.contextPath}/user?method=PictureCheckCode&"+Math.random());
	}
      function check(){
    	  //if(document.getElementById("form1").username.value==""){
    		  if($("#username").val()==""){
    		  alert("请输入用户名！");
    		  $("#username").focus();//把光标移到username下
    		  return false;
    	  }
    	 // if(document.getElementById("form1").password.value==""){
    		 if($("#password").val()==""){
    			 alert("请输入密码！");
    			 $("#password").focus();
    			 return false;
    		 }
      }
      
      $(document).ready(function(){
      //校验验证码
  	$("#checkCode").blur(function(){
  		console.log('333');
		var checkCode= $("#checkCode").val();
/* 		 $.post("${pageContext.request.contextPath}/user?method=checkMyReload&checkCode=" + checkCode,function(data){
	   		  if(data == 1){
	   			  $("#checkCodeMsg font").html("验证码不正确");
	   		  } else {
	   			$("#checkCodeMsg font").html("");
	   		  }
		 }); */
		 $.ajax({
			 type:"POST",
			 url:"${pageContext.request.contextPath}/user",
			 data:{method:"checkMyReload",checkCode:checkCode},
			 success:function(data){
				 if(data == 1){
		   			  $("#checkCodeMsg font").html("验证码不正确");
		   		  } else {
		   			$("#checkCodeMsg font").html("");
		   		  }
			 }
		 })
	});
      
      });
</script>
<body>
  <br>
  <center><h3 style="color:red;">${msg }</h3></center>
  <form id="form1" name="form1" method="post" action="${pageContext.request.contextPath}/user" onSubmit="return check()">
     <input type="hidden" name="method" value="login">
     <table width="371" height="230" border="0" align="center" cellpadding="0" cellspacing="0" background="images/login.jpg">
           <tr>
                 <td height="120" colspan="3" class="word_dark">&nbsp;</td>
           </tr>
           <tr>
                <td width="53" align="center" valign=" top" class="word_dark">&nbsp;</td>
                <td width="216" align="center" valign="top" class="word_dark">
                	<table width="100%" height="100%">
                      	<tr>
                           <td> 用户名：</td>
                           <td><input id="username" type="text" name="username" class="login"></td>
                      </tr>
               	</table>
               	</td>
               <td width="94" valign="top" class="word_dark"></td>
            </tr>
  
            <tr>
               <td width="53" align=" center" valign="top" class="word_dark">&nbsp;</td>
               <td width="216" align="center" valign="top" class="word_dark">
               <table width="100%" height="100%">
            <tr>
              <td>密&nbsp;&nbsp;码：</td>
              <td><input id="password" type="password" name="password" class="login"></td>
            </tr>
              </table>
              </td>
              <td width="94" valign="top" class="word_dark"></td>
           </tr>
            <tr>
            	<td width="53" align=" center" valign="top" class="word_dark">&nbsp;</td>
               <td width="216" align="center" valign="top" class="word_dark">
               <table width="100%" height="100%">
			   <td>验证码</td>
		      <td><input name="checkCode" type="text" id="checkCode" title="验证码区分大小写"  size="8" ,maxlength="4" /></td>
		      <td>  
                <span id="checkCodeMsg"><font color="red"></font>  
                </span>  
            </td> 
            </table>
            <img src="${pageContext.request.contextPath}/user?method=PictureCheckCode" id="CreateCheckCode" align="middle">  
		 <a href="javascript:void()" onclick="myReload()"> 看不清,换一个</a>  
	     </tr>
           <tr>
              <td width="53" align="center" valign="top" class="word_dark">&nbsp;</td>
              <td width="216" align="center" valign="top" class="word_dark">
              <input name="Submit" type="submit" class="btn_bg" value="进入">
              </td>
              <td width="94" valign="top" class="word_dark">
              </td>
           </tr>
     </table>
   </form>
</body>
</html>
